﻿using HDJ.Framework.Core;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace HDJ.Framework.Core
{
    public class JsonTestRuntime : MonoBehaviourExtend
    {
        private void Awake()
        {
            Timer t = TimerManager.SetTimerNoLimitRepeat(1f);
            t.OnEveryRepeatComplete += (t1) =>
            {
            // JsonTestClass j = new JsonTestClass();
            //for (int i = 0; i < 20; i++)
            //{
            //    string s = JsonUtils.ToJson(10);
            //    Debug.Log(s);
            //    int obj= JsonUtils.FromJson<int>(s);
            //    Debug.Log(obj);
            //}

            Dictionary<JsonTestClass, string> dic = new Dictionary<JsonTestClass, string>();
                dic.Add(new JsonTestClass(), "Test");
                string s = JsonUtils.ToJson(dic);
                Debug.Log(s);
                Dictionary<JsonTestClass, string> obj = JsonUtils.FromJson<Dictionary<JsonTestClass, string>>(s);
                Debug.Log(new List<string>(obj.Values)[0]);
            };
        }
        protected override void OnUpdate()
        {

        }



        public class JsonTestClass
        {
            public Vector3 v3 = new Vector3(1, 1, 1);
            public Vector2 v2 = Vector2.one;
        }
    }
}
